package com.pokeoffice.calendar;

import java.util.List;

/**
 * The Class Year.
 */
public class Year {

	/** The Constant DEFAULT_YEAR. */
	private static final int DEFAULT_YEAR = 1970;
	
	/** The year. */
	private int year;

	/** The days. */
	private List<Day> days;
	
	/**
	 * Instantiates a new year.
	 */
	public Year() {
		this(DEFAULT_YEAR);
	}
	
	/**
	 * Instantiates a new year.
	 *
	 * @param year the year
	 */
	public Year(int year) {
		this.year = year;
		int numDays = 365;
		
		if (isLeap()) {
			numDays++;
		}
		
		for (int i = 0; i < numDays; i++){
			days.add(new Day(i));
		}
	}

	/**
	 * Gets the day.
	 *
	 * @param d the d
	 * @return the day
	 */
	public Day getDay(int d){
		return days.get(d);
	}

	/**
	 * Checks if is leap.
	 *
	 * @return true, if is leap
	 */
	public boolean isLeap(){
		return (year % 4 == 0) && (!(year % 100 == 0) || (year % 400 == 0));
	}

	/**
	 * The year.
	 *
	 * @return the int
	 */
	public int theYear(){
		return year;
	}

	/**
	 * Gets the year.
	 *
	 * @return the year
	 */
	public List<Day> getYear(){
		return days;
	}
	
	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	public String toString(){
		return "" + year;
	}

}
